<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://cdn.jsdelivr.net/npm/@js-preview/docx@1.3.1/lib/index.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/@js-preview/docx@1.3.1/lib/index.umd.js"></script>


    <style>
        body,
        .main {
            margin: 0;
            padding: 0;
        }
    </style>
</head>


<body>
    <div id="containter" class="main"></div>
</body>

<script>
    function getURLParameter(parameterName) {
        const urlParams = new URLSearchParams(window.location.search);
        return urlParams.get(parameterName);
    }

    const myDocxPreviewer = jsPreviewDocx.init(document.getElementById('containter'));
    const fname = getURLParameter('file');
    if (!fname) {
        alert('Failed to get the word file')
    }
    myDocxPreviewer.preview(fname).then(res => {
        console.log('预览完成');
    }).catch(e => {
        console.log('预览失败', e);
    })
</script>

</html>